﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Antioch.Base
{
    [Jemgine.Engine.Node, Jemgine.Engine.Category("Antioch System")]
    public class ContinueGame : Jemgine.Data.ScriptNode
    {
        public ContinueGame()
        {
            AddInput("Fire", null);
        }

        public override void FireTerminal(int InputID, Jemgine.Data.ScriptPayload Payload)
        {
            var GameStateModule = Sim.GetModule<GameStateModule>();
            if (GameStateModule != null) GameStateModule.InitiateGame(GameStateModule.PreviousSavedGame, true);
        }
    }

    [Jemgine.Engine.Node, Jemgine.Engine.Category("Antioch System")]
    public class EnableAutosave : Jemgine.Data.ScriptNode
    {
        public EnableAutosave()
        {
            AddInput("Fire", null);
        }

        public override void FireTerminal(int InputID, Jemgine.Data.ScriptPayload Payload)
        {
            var GameStateModule = Sim.GetModule<GameStateModule>();
            if (GameStateModule != null) GameStateModule.AutosaveEnabled = true;
        }
    }

    [Jemgine.Engine.Node, Jemgine.Engine.Category("Antioch System")]
    public class DisableAutosave : Jemgine.Data.ScriptNode
    {
        public DisableAutosave()
        {
            AddInput("Fire", null);
        }

        public override void FireTerminal(int InputID, Jemgine.Data.ScriptPayload Payload)
        {
            var GameStateModule = Sim.GetModule<GameStateModule>();
            if (GameStateModule != null) GameStateModule.AutosaveEnabled = false;
        }
    }

    [Jemgine.Engine.Node, Jemgine.Engine.Category("Antioch System")]
    public class CanContinue : Jemgine.Data.ScriptNode
    {
        public CanContinue()
        {
            AddInput("Fire", null);
            AddOutput("Out", null);
        }

        public override void FireTerminal(int InputID, Jemgine.Data.ScriptPayload Payload)
        {
            var GameStateModule = Sim.GetModule<GameStateModule>();
            if (GameStateModule != null && GameStateModule.PreviousSavedGame != null) OutputTerminals[0].Fire(Payload);
        }
    }


}
